var cfg = require('../../utils/cfg');
var socketUtil = require('../../utils/socketUtil');

var app = getApp();

Page({
	data: {
    hasQuestion: false,
    hasNewMsg: {
      question: false,
      ask: true
    },
    userInfo : {},
    balance : 0
	},
  
	onLoad: function(options) {

		var _self = this;
    _self.setData({
      userInfo: app.globalData.userInfo
    })
	
	},

  onReady : function() {
    let that = this;
    that.getUserInfo();
  },

  getUserInfo : function() {
    let that = this;
    wx.request({
      url: cfg.host + cfg.mwurl.getUserInfo,
      data: {
        openId: wx.getStorageSync('loginUser').openId
      },
      success: function (res) {
        if (1000 !== res.data.code) {
          wx.showToast({
            title: res.data.message,
            icon: 'none',
            duration: 2000
          })

          return;
        }
        let userInfo = res.data.data;
        that.setData({ balance: userInfo.balance});
      },
      header: {
        'content-type': 'application/x-www-form-urlencoded' // 默认值
      },
      method: 'POST'
    })
  }

})